package com.itfallrain.service;

import com.itfallrain.dao.CarMapper;
import com.itfallrain.entity.Car;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CarService {
    @Autowired
    private CarMapper carMapper;
//    查询受影响的行说
    public long getCarCount(){
        return carMapper.getCarCount();
    }
//     获取数据库所有数据
    public List<Map<String,Object>> getAll(int page,int limit){
        Map<String,Object> map=new HashMap<String, Object>();
       int start=(page-1)*limit;
       map.put("start",start);
       map.put("limit",limit);
       return carMapper.selectAll(map);
    }
//    新增客户信息
    public int selectAlls(Car car){
        return carMapper.insert(car);
    }
//    删除客户信息
    public int delectAlls(int id){

        return carMapper.deleteKey(id);
    }
//    修改客户信息
    public int updataAlls(Car car){
        return carMapper.updateByPrimaryKeySelective(car);
    }
}
